<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns="http://www.w3.org/1999/xhtml">

    <ui:define name="top">
        Your order history
    </ui:define>

    <ui:define name="left">
    </ui:define>

    <ui:define name="body">
        <c:choose>
            <c:when test="#{not empty userCTRL.priorOrders}">
                <c:forEach items="#{userCTRL.priorOrders}" var="order">
                    <div>
                        Order Summary:<br />
                        <span style="font-weight:bold;">Sales Order Number: #{order.id}</span><br />
                        <span style="font-weight:bold;">Sales Order Date: &nbsp;&nbsp;#{order.date}</span><br />
                        <br />
                        <div style=" background-color: gray; font-weight: bold;">Billing Information</div>
                        <span style="font-weight: bold;">#{order.user.firstName} #{order.user.lastName}</span><br />
                        #{order.user.address}<br />
                        #{order.user.city},#{order.user.state} #{order.user.zip}<br />
                        <br />
                        <hr/>
                        <c:forEach items="#{order.orderLinks}" var="items">
                            #{items.quantity}x($#{items.item.price}) #{items.item.name} <br />
                            <hr/>
                        </c:forEach>
                        <br />
                        <span style="font-weight: bold">Total Amount: </span>$#{order.amount}
                    </div>
                    <br/><br/><br/>
                </c:forEach>
            </c:when>
            <c:otherwise>
                You haven't placed any orders!
            </c:otherwise>
        </c:choose>
        
    </ui:define>

</ui:composition>
